package cn.edu.njust.alg.leetcode;

public class Leetcode_136_singleNumber {

	/*
	 * Given an array of integers, every element appears twice except for one.
	 * Find that single one.
	 * 
	 * Note: Your algorithm should have a linear runtime complexity. Could you
	 * implement it without using extra memory?
	 */
	public int singleNumber(int[] nums) {
		int res = 0;
		for (int num : nums) {
			res ^= num;
		}
		return res;

	}

	public static void main(String[] args) {
		int[] a = { 2, 2, 3, 5, 7, 7, 5 };
		System.out.println(new Leetcode_136_singleNumber().singleNumber(a));
	}

}
